<template>
    <div class="container">
        <div class="drag-bg" id="resizeCover"></div>
        <navigation-bar></navigation-bar>
        <div class="editContent">
            <!--<div class="drag-bg" id="resizeCover"></div>-->
            <div class="edit-main clearfix">
                <!--<catalog></catalog>-->
                <edit-area></edit-area>
                <!-- <material></material> -->
                <cnki></cnki>
            </div>
            <div class="edit-footer">
                <span class="float-l" v-text="title" :title="title"></span>
                <span class="float-r">字数：{{contentLegth}}</span>
            </div>
        </div>
        <white-cloth></white-cloth>
        <show-image></show-image>
        <upload-queue v-show="showUploadQueue"></upload-queue>
    </div>
</template>

<script>
    import NavigationBar from './NavigationBar'
    import EditArea from './editor/EditArea'
    import cnki from './resource/resourceList'
    import WhiteCloth from './WhiteCloth'
    import ShowImage from './ShowImage'
    import {Observer} from '../core/util'
    import {mapState, mapMutations} from 'vuex'
    import uploadQueue from "./resource/uploadQueue"

    export default {
        components: {
            NavigationBar,
            // Catalog,
            EditArea,
            // Material,
            cnki,
            WhiteCloth,
            ShowImage,
            uploadQueue
        },
        destroyed() {
            // 由于dom会消失，所以需要移除这些vue组件相关的事件
            Observer.remove('openMembers clickMark editorClick contentchange hidecloth showcloth showcolorlist selectionchange editorCompleted triggerRightBar showunorderedlist showorderedlist showtablepicker execCommand globalClick showImage showPopup');
        },
        computed: {
            ...mapState(['title', 'contentLegth', 'showUploadQueue'])
        },
        methods: {
            ...mapMutations(['initResize']),
            ...mapMutations(["triggerRightBar", "setCurrShowingResoLib"]),
        },
        mounted(){
            // 初始化resize对象
            this.initResize({
                maxWidth: 1200,
                minWidth: 300,
                bookResize: 590,
                targetID: 'resizeBox',
                controllerID: 'resizectlr',
                coverID: 'resizeCover',
                leftAreaID: 'leftArea',
                bookAreaID: 'bookArea'
            });
            // 编辑器打开时默认开着备课组资源
            // 课题不是
            this.triggerRightBar(true);
            if(window.typeId){
                // this.setCurrShowingResoLib('cnki');
                this.setCurrShowingResoLib('prep');
                // this.setCurrShowingResoLib('scho');
            }else{
                // 课题项目
                this.setCurrShowingResoLib('cnki');
            }

        }
    }
</script>
